<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //  alert("你好！")
        var str = ""
        //入门与语法
        for (var i = 1; i <= 9; i++) {
            for (var j = 1; j <= i; j++) {
                str = str + j + "*" + i + "=" + j * i + " "
            }
            str += "\n"
        }
        //console.log(str);
        //数组
        var arr = [12, 95, 67, 23, 2, 69]
        var temp
        for (var j = 1; j < arr.length; j++) {
            for (var i = 0; i < arr.length - j; i++) {
                if (arr[i] < arr[i + 1]) {
                    temp = arr[i]
                    arr[i] = arr[i + 1]
                    arr[i + 1] = temp
                }
            }
        }
     //   console.log(arr);

        //函数
        function BiJiao(arr){
            var temp 
            if(arr[0]<arr[1])
            {
                temp = arr[0]
                arr[0]=arr[1]
                arr[1] =temp
            }
            
        }
        var arr1 = [5,8]
        var arr2 = [34,98]
        BiJiao(arr1)
        console.log(arr1);
        BiJiao(arr2)
        console.log(arr2);

        // 冒泡排序函数
        function MaoPao(arr)
        {
             var temp
            for (var j = 1; j < arr.length; j++) {
                for (var i = 0; i < arr.length - j; i++) {
                    if (arr[i] < arr[i + 1]) {
                        temp = arr[i]
                        arr[i] = arr[i + 1]
                        arr[i + 1] = temp
                    }
                }
            }
        }
        
        var  arr3 = [23,45,12,9,45,67,14]
        MaoPao(arr3)
        console.log(arr3);
        

    </script>
</body>

</html>